angular.module('feedback', [])
.controller('feedbackCtrl', ['$scope', 'httpService', 'alertmsg', function($scope, httpService, alertmsg) {
  $scope.feedback = {};

  var firstsubmit = true;
  $scope.isSubmit = false;

  $scope.submitFeedback = function(bool, feedback) {
    if (firstsubmit) {
      if (!bool) {
        firstsubmit = false;
        httpService.query('web/feedback', feedback, 'post').then(function(res) {
          $scope.firstsubmit = true;
          if (res.code == 200) {
            $scope.feedback = {};
            alertmsg('提交成功！');
          } else {
            alertmsg(res.msg);
          }
        }, function(){
          firstsubmit = true;
        });
      } else {
        $scope.isSubmit = true;
      }
    } else {
      alertmsg('请不要多次提交！')
    }
  }
}]);
